<?php

if (!defined('DIR_SEP'))
    define('DIR_SEP', DIRECTORY_SEPARATOR);

if (!defined('MODULES_DIR'))
    define('MODULES_DIR', dirname(__FILE__).DIR_SEP."..".DIR_SEP);

require_once(MODULES_DIR."IManager.inc");
require_once(MODULES_DIR."log.inc");
require_once(MODULES_DIR."config.inc");
require_once(MODULES_DIR."util.inc");
require_once(MODULES_DIR."social".DIR_SEP."social.inc");

class SocialManager implements IManager
{
	public function getAdminMenu()
	{
		//get admin menu should be deprecated, and managed in get admin menu.
		//should be managed in settings page, add tab for blog settings
	}
	
	public function getMenu()
	{
		global $G_HOME;
		
		$result = "
				<style>
					li#socialTagMenuItem
					{
						cursor:pointer;
						margin:10px 0;
						position:relative;
					}
					div#socialTags
					{
						border:solid 1px gray;
						display:none;
						position:absolute;
						top:16px;
						left:0px;
						background-color:white;
					}
					div#socialTags table 
					{
						width:100%;
						padding:1px;
						margin:0px;
						border-collapse:collapse;
					}
					td.socialTag
					{
						border:solid 1px #e0e0e0;
						background-color:white;
						margin:2px;
						cursor:pointer;
						white-space:nowrap;
						padding:4px;
					}
					td.socialTag label
					{
						font-size:12px;
						font-family:Trebuchet, Tahoma, Arial;
						cursor:pointer;
					}
					td.socialTag img
					{
						margin-right:8px;
						cursor:pointer;
					}
					.selectedSocial
					{
						border:solid 1px #ccc;
						background-color:#eee;
					}
				</style>";
		$result .= "<li id='socialTagMenuItem' class='navCategory'><img src='".$G_HOME."/images/social.png'></img>
						<div id='socialTags'>
							<table>
								<tbody>
									<tr>
										<td class='socialTag'><img src='".$G_HOME."/images/social/facebook.png'/><label>Facebook</label></td>
										<td class='socialTag'><img src='".$G_HOME."/images/social/delicious.png'/><label>Delicious</label></td>
									</tr>
									<tr>
										<td class='socialTag'><img src='".$G_HOME."/images/social/twitter.png'/><label>Twitter</label></td>
										<td class='socialTag'><img src='".$G_HOME."/images/social/digg.png'/><label>Digg</label></td>
									</tr>
								</tbody>
							</table>
						</div>
					</li>";
		
		$result .= "<script>
						$('li#socialTagMenuItem').hover( function()
						{
							$('div#socialTags').show();
						},
						function()
						{
							$('div#socialTags').hide();
						} );
						
						$('div#socialTags td').hover( function() 
						{ 
							$(this).addClass('selectedSocial');
						}, 
						function() 
						{
							$(this).removeClass('selectedSocial');
						} );

						var socialUrls = new Array();						
						socialUrls['Facebook'] = 'http://www.facebook.com/share.php?u={0}&t={1}';
						socialUrls['Delicious'] = 'http://delicious.com/save?url={0}&title={1}&notes=';
						socialUrls['Twitter'] = 'http://twitter.com/home/?status={0} {1}';
						socialUrls['Digg'] = 'http://digg.com/submit/?phase=2&url={0}&title={1}&bodytext=';
						
						$('div#socialTags td').click( function()
						{
							var socialNetwork = $(this).children('label').text();
							
							var url = socialUrls[socialNetwork];
							url = url.replace('{0}',encodeURIComponent(location.href));
							url = url.replace('{1}',encodeURIComponent(document.title));
							window.open(url);
						} );
					</script>";

		return $result;
	}
}

?>